use std::rc::Rc;

fn base(){
    let rc_example = "Rc Examples".to_string();
    {
        println!("-----rc_a is created----");
        let rc_a: Rc<String> = Rc::new(rc_example);

        println!("RefCount of rc_a: {}", Rc::strong_count(&rc_a));

        //let rc_a_2: Rc<String> = rc_a; // moved  , Rc-no-impl-copy [default moved]

        {
            let rc_a_2: Rc<String> = rc_a.clone();  //must use clone to add ref count
            println!("RefCount of rc_a: {}", Rc::strong_count(&rc_a_2));
        }
        println!("after rc_a_2 droped RefCount of rc_a: {}", Rc::strong_count(&rc_a));
    }
}

pub fn main(){
    println!("this is rc");
    base();
}
